import base64
import pickle
import subprocess
from subprocess import Popen


def pickle_dumps_to_str(obj):
    try:
        s = base64.encodebytes(pickle.dumps(obj)).decode()
        f = open('db.obj','w')
        f.write(s)
        f.close()
    except pickle.PicklingError:
        print('转化str失败')
        pass
class Student:
    def __init__(self):
        self.name = '123'
    def talk(self):
        print(self.name)

def start_script():
    student = Student()
    # 此时传递的将是序列化后的 Student 对象实例（注意和使用 `eval` 的区别）
    str = pickle_dumps_to_str(student)
    print(str)
    # commands = ['python3', 'objget.py',
    #             str]
    # subprocess.call(commands)
if __name__ == '__main__':
    start_script()